<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>车辆信息</title>

<%@ include file="/wf/public/meta_wf.jsp"%>

<script src="${ctx}/gzcgwsp/resources/js/prototype.js" type="text/javascript"></script>
<script src="${ctx}/gzcgwsp/resources/js/YwUtil.js" type="text/javascript"></script>
<script src="${ctx}/resources/components/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="${ctx}/gzcgwsp/resources/css/common-ui.css" />

<script>
   Ext.onReady(function(){
   	  Ext.getBody().mask("请放入IC卡，请稍候......");
		 Ext.Ajax.request({
			url: 'bus-iccard-manage!readCardInfo.action',
			method: 'POST',
			success: function(response){
			 Ext.getBody().unmask();
			 //document.getElementById("prompt").innerHTML="";
			 if(response.responseText!=""){
			 	document.getElementById("prompt").innerHTML="";
			 	var obj = Ext.util.JSON.decode(response.responseText);
			  document.getElementById("cphm").value=obj.cphm;
 			  document.getElementById("busId").value=obj.id;
 			  document.getElementById("bzh").value=obj.clbh;
 			  document.getElementById("gsmc").value=obj.gsmc;  
 			  document.getElementById("fdjh").value=obj.fdjh;  
 			  document.getElementById("cjh").value=obj.cjh;  
 			  document.getElementById("yxrq").value=obj.yxsj;
 			   document.getElementById("busId").value=obj.id;
			 }else{
				 Ext.Msg.alert('系统提示', '没有读取到卡内数据!');
			 }
			    
			},
			failure: function(){
				Ext.Msg.alert('系统提示', '读取ic卡失败!');
			}
			
		});
   });




//读取卡内信息
function readCard(){
		Ext.getBody().mask("请放入IC卡，请稍候......");
		 Ext.Ajax.request({
			url: 'bus-iccard-manage!readCardInfo.action',
			method: 'POST',
			success: function(response){
			 Ext.getBody().unmask();
			 //document.getElementById("prompt").innerHTML="";
			 if(response.responseText!=""){
			 	document.getElementById("prompt").innerHTML="";
			 	var obj = Ext.util.JSON.decode(response.responseText);
			  document.getElementById("cphm").value=obj.cphm;
 			  document.getElementById("busId").value=obj.id;
 			  document.getElementById("bzh").value=obj.clbh;
 			  document.getElementById("gsmc").value=obj.gsmc;  
 			  document.getElementById("fdjh").value=obj.fdjh;  
 			  document.getElementById("cjh").value=obj.cjh;  
 			  document.getElementById("yxrq").value=obj.yxsj;
 			   document.getElementById("busId").value=obj.id;
			 }else{
				 Ext.Msg.alert('系统提示', '没有读取到卡内数据!');
			 }
			    
			},
			failure: function(){
				Ext.Msg.alert('系统提示', '读取ic卡失败!');
			}
			
		});
}


//打卡
function printCard(){
 	 var busId=document.getElementById("busId").value;
	 var url="bus-iccard-manage!printViewCard.action?id="+busId;
    YwUtil.openWin({url: url, w: 600, h: 300});
}

//发卡
function sendcard(){
	 	 Ext.Ajax.request({
			url: 'bus-iccard-manage!sendIccard.action',
			method: 'POST',
			success: function(response){
			Ext.getBody().unmask();
			var qyid = response.responseText;
				if(qyid!=""){
				 	alert("数据已经存在");
				}else{
					alert("数据成功写入到卡里");
				}
			},
			failure: function(){
				Ext.Msg.alert('系统提示', '读取ic卡失败!');
			}
			
		});

}

//修改有效期
function updateCard(){
	var busId=document.getElementById("busId").value;
 	 Ext.Ajax.request({
			url: 'bus-iccard-manage!updateCard.action?id='+busId,
			method: 'POST',
			success: function(response){
			Ext.getBody().unmask();
			var qyid = response.responseText;
				if(qyid!=""){
				 	alert("数据已经存在");
				}else{
					alert("数据成功写入到卡里");
				}
			},
			failure: function(){
				Ext.Msg.alert('系统提示', '读取ic卡失败!');
			}
		});
}



</script>
</head>

<body>
<form action="bus-iccard-manage.action" method="post" >
<input type="hidden" id="busId" name="busId" value="${busId}"/>
  <table width="100%" border="0" cellspacing="2" cellpadding="2">
    <tr>
      <td>
        <table width="100%" border="0" cellspacing="2" cellpadding="2" class="tpl_list_blueui">
          <tr>
            <td height="20" width='50%' align="center" bordercolor="#B3D9D9">
              &nbsp;&nbsp;
              <font size="4">车辆标识IC卡管理</font>
            </td>
          </tr>
        </table>
      </td>
    </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td>
       <table width="100%" border="1" cellspacing="2" cellpadding="2" class="tpl_list_blueui">
          <tr>
            <td height="20" bordercolor="#B3D9D9" bgcolor="#D9E8FB">
              <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="50%">&nbsp;&nbsp;<b>车辆信息列表</b></td>
                  <td width="50%" align="right">
                    <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#D9E8FB">
                      <tr>
                        <td height="20">&nbsp;</td>
                        
                         <td width="100">
                          <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#D9E8FB" onmouseover="this.className='tpl_btn_omover'" onmousedown="this.className='tpl_btn_omdown'" onmouseout="this.className='tpl_btn_omout'" 
                          onclick="readCard();">
                            <tr>
                              <td height="20" align="center"><img src="${ctx}/resources/images/icons1616/Edit.gif" />读取卡内数据</td>
                            </tr>
                          </table>
                        </td>
                        <!-- 
                         <td width="120">
                          <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#D9E8FB" onmouseover="this.className='tpl_btn_omover'" onmousedown="this.className='tpl_btn_omdown'" onmouseout="this.className='tpl_btn_omout'" onclick="updateCard();">
                            <tr>
                              <td height="20" align="center"><img src="${ctx}/resources/images/icons1616/Edit.gif" />修改IC卡有效期</td>
                            </tr>
                          </table>
                        </td>
                       
                        <td width="100">
                          <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#D9E8FB" onmouseover="this.className='tpl_btn_omover'" onmousedown="this.className='tpl_btn_omdown'" onmouseout="this.className='tpl_btn_omout'" onclick="delCard();">
                            <tr>
                              <td height="20" align="center"><img src="${ctx}/resources/images/icons1616/Edit.gif" />清除IC卡信息</td>
                            </tr>
                          </table>
                        </td>
                       
                    	<td width="100">
                          <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#D9E8FB" onmouseover="this.className='tpl_btn_omover'" onmousedown="this.className='tpl_btn_omdown'" onmouseout="this.className='tpl_btn_omout'" onclick="sendcard();">
                            <tr>
                              <td height="20" align="center"><img src="${ctx}/resources/images/icons1616/Edit.gif" />重发IC卡</td>
                            </tr>
                          </table>
                        </td>
                       -->
                      </tr>
                    </table>
                  </td>
                </tr>
            </table></td>
          </tr>
      </table></td>
    </tr>
    <tr>
      <td>
		<table width="100%" border="1" cellspacing="0" cellpadding="2" class="tpl_list_blueui">
            <tr>
               <td bordercolor="#B3D9D9" colspan="2" height="25" align="right">标识编号：</td>
              <td colspan="3" bordercolor="#B3D9D9" style="padding-right:50px;">
                <input type="text" id="bzh" readonly/>
              </td>
              <td bordercolor="#B3D9D9" colspan="2" height="25" align="right">车牌号：</td>
              <td colspan="3" bordercolor="#B3D9D9" style="padding-right:50px;">
                <input type="text" id="cphm" size="35" readonly/>
              </td>
            </tr>
             <tr>
              <td bordercolor="#B3D9D9" colspan="2" height="25" align="right">公司名称：</td>
              <td colspan="3" bordercolor="#B3D9D9" style="padding-right:50px;">
                <input type="text" id="gsmc"  size="35"  readonly/>
              </td>
              <td bordercolor="#B3D9D9" colspan="2" height="25" align="right">企业等级：</td>
              <td colspan="3" bordercolor="#B3D9D9" style="padding-right:50px;">
                <input type="text" id="qydj"  size="35" readonly/>
              </td>
            </tr>
            <tr>
              <td bordercolor="#B3D9D9" colspan="2" height="25" align="right">发动机号：</td>
              <td colspan="3" bordercolor="#B3D9D9" style="padding-right:50px;">
                 <input type="text" id="fdjh"   size="35" readonly/>
              </td>
              <td bordercolor="#B3D9D9" colspan="2" height="25" align="right">车架号：</td>
              <td colspan="3" bordercolor="#B3D9D9" style="padding-right:50px;">
                <input type="text" id="cjh"  size="35"  readonly/>
              </td>
            </tr>
           
    
            <tr>
              <td bordercolor="#B3D9D9" colspan="2" height="25" align="right">有效日期：</td>
              <td colspan="3" bordercolor="#B3D9D9" style="padding-right:50px;">
                 <input type="text" id="yxrq" readonly size="40"/>
              </td>
              <td colspan="3" bordercolor="#B3D9D9" style="padding-right:50px;">
                <div id="prompt"><font color='red'>请放卡</font></div>
              </td>
            </tr>
            <tr>
           
            
            </tr>
	     </table>
     </td>
    </tr>

  </table>

</form>
</body>
</html>
